package edu.gatech.cc.liam.geometry.linear.programming;

import java.util.ArrayList;

import edu.gatech.cc.liam.geometry.linear.NPoint;
import edu.gatech.cc.liam.geometry.linear.PointSet;
import edu.gatech.cc.liam.geometry.linear.Polytope;

public class MultiObjectiveLP {
	
	//public Polytope theConstraints;
	//public ArrayList<NPoint> objectiveFuncs;
	//public String probName = "unnamed";

	public static PointSet solveMOLP_AllBruteForce(Polytope theConstraints, ArrayList<NPoint> objectiveFuncs) {
		PointSet feasibleSet = theConstraints.getExtremePoints();
		return solveMOLP_givenVerticies(feasibleSet, objectiveFuncs);
	} 

	/**
	 * @param feasibleSet
	 * @return
	 */
	public static PointSet solveMOLP_givenVerticies(PointSet feasibleSet, ArrayList<NPoint> objectiveFuncs) {
		assert feasibleSet.dimensions() == objectiveFuncs.get(0).dimensions();
		double[] zeros = new double[objectiveFuncs.size()];
		PointSet answerSet = new PointSet();
		for(NPoint feasibleVert : feasibleSet) {
			NPoint theSum = new NPoint(zeros);
			for(int i=0; i<objectiveFuncs.size(); i++) {
				theSum.values[i] = feasibleVert.dotProduct(objectiveFuncs.get(i));
			}
			answerSet.add(theSum);
		}
		answerSet.removeInteriorPoints();
		return answerSet;
	}
	
	
}
